/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package controlPlaylisted;


import Response.ResponseUser;
import Request.RequestUser;
import dataPlaylisted.User;
import java.util.ArrayList;

/**
 *
 * @author Administrador
 */
public class loginCommand implements ControlUserCommand{

    public void execute(RequestUser _req, ResponseUser _resp){

        boolean login = false;

        int size = _req.getObjectList().size();

        ArrayList<User> _users;
        _users = _req.getObjectList();

        ArrayList<User> logged_user;
        logged_user = new ArrayList<User>();

        User req_login;
        req_login = _users.get(size - 1);

        for (int i=0; i < (size - 1); i++){
            if (req_login.getUserLogin().equals(_users.get(i).getUserLogin()))
                if (req_login.getUserPass().equals(_users.get(i).getUserPass())){
                    logged_user.add(0,_users.get(i));
                    _resp.setObjectList(logged_user);
                    login = true;
                }
        }
    }

}
